using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GameAOT;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class UIMail : UIBaseWindow
    {
        /// <summary>
        /// 静态配置
        /// </summary>
        private static UICreateConfig _createConfig = new()
        {
            prefabName = nameof(UIMail),
            layer = EUILayer.Normal,
        };

        /// <summary>
        /// 创建UI的配置
        /// </summary>
        public override IUICreateConfig createConfig => _createConfig;

        #region Template Generate,don't modify
        protected partial class UIB_UIMail
        {
            #region ObjectBinding Generate
            public GameObject panel { protected set; get; }
            public GameObject mailPanel { protected set; get; }
            public IQIGame.Onigao.Framework.ExButton bG { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.GameObject>("panel", out var __tbv0);
                this.panel = __tbv0;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("mailPanel", out var __tbv1);
                this.mailPanel = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExButton>("bG", out var __tbv2);
                this.bG = __tbv2;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify


        protected UIB_UIMail ui { get; set; }

        private LoopScrollAdapter<UIN_MailCell> LoopScrollAdapter;
        protected override void BeforeInit()
        {
            ui = new UIB_UIMail();
            ui.InitBinding(this.csObjBind);
        }
        public UIN_MailListPanel MailListPanel = null;
        public UIN_MailDetailPanel MailDetailPanel = null;
        protected override void OnInit()
        {
            this.MailListPanel = this.InitChildNode<UIN_MailListPanel>(this.ui.panel);
            this.MailDetailPanel = this.InitChildNode<UIN_MailDetailPanel>(this.ui.mailPanel);
            this.ui.bG.AddClickEvent(this.Close);
        }

        protected override void OnDispose()
        {
            this.MailListPanel = null;
            this.MailDetailPanel = null;
        }

        protected override void OnShow(UIBaseData data)
        {
            this.MailListPanel.Show(true);
            this.MailDetailPanel.Hide();
        }

        protected override void OnHide()
        {

        }
    }
}
